# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="x86_64 Linux hosted cross toolchains"
HOMEPAGE="https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads"
SRC_URI="https://developer.arm.com/-/media/Files/downloads/gnu/${PV}.rel1/binrel/arm-gnu-toolchain-${PV}.rel1-x86_64-${PN}.tar.xz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 x86"
RESTRICT="binchecks bindist mirror strip"
IUSE=""

S=${WORKDIR}

OPT_DIR="opt/arm-gnu-toolchain"

RDEPEND="sys-libs/ncurses-compat"

src_unpack() {
	# skip
	:
}


src_install() {
	dodir /

	mkdir -p "${D}/${OPT_DIR}" || die

	cd "${D}/${OPT_DIR}" || die

	unpack ${A} || die

	mv "arm-gnu-toolchain-${PV}.rel1-x86_64-${PN}" ${PVR} || die

	cd ${D}/${OPT_DIR}/${PVR}/bin || die
	bins=($(ls)) || die

	for var in ${bins[@]}; do
		dosym "../../${OPT_DIR}/${PVR}/bin/${var}" /usr/bin/${var} || die
	done
}
